//
//  MCAddFreightCell.swift
//  StoreManage
//
//  Created by MC on 2018/9/20.
//  Copyright © 2018年 MC. All rights reserved.
//

import UIKit

class MCAddFreightCell: UITableViewCell {

    var model = MCChooseAreaModel() {
        didSet {
            provinceLabel.text = model.proName
            
            if model.selectedCitysStr.isEmpty {
                citysLabel.text = model.allCitysStr
            } else {
                citysLabel.text = model.selectedCitysStr
            }
        }
    }
    
    public class func customCell(tableView:UITableView) -> MCAddFreightCell {
        
        let reuseIdentifier = "MCHomePageCell";
        var cell = tableView.dequeueReusableCell(withIdentifier: reuseIdentifier)
        
        cell = MCAddFreightCell(style: .default, reuseIdentifier: reuseIdentifier)
        
        return cell as! MCAddFreightCell
    }
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        self.selectionStyle = UITableViewCellSelectionStyle.none
        
        self.addSubview(provinceLabel)
        self.addSubview(citysLabel)
        self.addSubview(lineView)

    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        provinceLabel.snp.remakeConstraints { (make) ->Void in
            make.left.top.equalTo(15)
            make.width.equalTo(60)
        }
        
        citysLabel.snp.remakeConstraints { (make) ->Void in
            make.left.equalTo(provinceLabel.snp.right).offset(10)
            make.right.equalTo(-15)
            make.top.equalTo(provinceLabel).offset(2)
            make.bottom.lessThanOrEqualTo(-15)
        }
        
        lineView.snp.remakeConstraints { (make) ->Void in
            make.left.right.bottom.equalTo(self)
            make.height.equalTo(1)
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    lazy var provinceLabel: UILabel = {
        let label = UILabel()
        label.font = MCFont(15)
        label.textColor = UIColor.MCAssist_B
        label.text = "XXX"
        return label
    }()
    
    lazy var citysLabel: UILabel = {
        let label = UILabel()
        label.font = MCFont(12)
        label.textColor = UIColor.MCGray_middle
        label.numberOfLines = 0
        label.text = "xxxx"
        return label
    }()

    lazy var lineView: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor.MCGray_light
        return view
    }()
}
